package device

import (
	"goAdapter/device/eventBus"
	"sync"
)

type CloudTemplate struct {
	Name        string       //云名称
	ReportTopic string       //上报节点数据的主题名
	Event       eventBus.Sub //事件
	IsOnline    bool         //是否在线
}

type CloudMapTemplate struct {
	Lock           sync.RWMutex
	Cloud          map[string]*CloudTemplate
	Num            int          //云总数
	ReportEventBus eventBus.Bus //事件总线
	IsReady        bool         //云已经初始化好
}

var CloudMap = CloudMapTemplate{
	Cloud:          make(map[string]*CloudTemplate),
	Lock:           sync.RWMutex{},
	Num:            0,
	ReportEventBus: eventBus.NewBus(),
	IsReady:        false,
}

func (d *CloudTemplate) Init(name string, topic string) {
	d.Name = name
	d.ReportTopic = topic
	d.IsOnline = false
	d.Event = eventBus.NewSub()
}
